 <template>
   <Card :shadow="shadow">
      <div class="card-name">
        <div class="name width1">费率设置</div>
      </div>
      <div class="content-con">
        <i-form ref="formValidate"
        :model="formValidate"
        label-position="right"
        :label-width="150"
        class="rate-item margin">
          <Form-item label="通道名称" size="large" prop="channel_name">
            <i-input v-model="formValidate.channel_name" size="large" placeholder="请输入通道名称"></i-input>
          </Form-item>
          <Form-item label="手续费类型" prop="fee_type">
            <RadioGroup v-model="formValidate.fee_type">
              <Radio label="0" size="large" border><span>百分比收费</span></Radio>
              <Radio label="1" size="large" border><span>固定收费</span></Radio>
              <Radio label="2" size="large" border><span>固定收费+百分比收费</span></Radio>
            </RadioGroup>
          </Form-item>
          <Form-item label="手续费费率(%)" prop="poundage">
            <i-input v-model="formValidate.poundage" size="large" placeholder="输入手续费费率"></i-input>
          </Form-item>
          <Form-item label="每笔手续费(元)" prop="sing_fee">
            <i-input v-model="formValidate.sing_fee" size="large" placeholder="输入每笔手续费"></i-input>
          </Form-item>
          <Form-item class="ban-btn">
            <i-button @click="handleSubmit()" class="save" size="large">保存</i-button>
            <i-button class="save" size="large" @click="btnClick1">返回</i-button>
          </Form-item>
        </i-form>
      </div>
   </Card>
 </template>

 <script>
 // import {
 //   channellist
 // } from '@/api/channel'
 import { mapMutations } from 'vuex'
 export default {
   name: 'rate',
   props:{
     shadow: {
       type: Boolean,
       default: false
     }
   },
   data() {
     return {
       formValidate: {
         channel_name: this.$route.params.row.channel_name,
         fee_type: '0',
         poundage: '10',
         sing_fee: '1'
       }
     };
   },
   methods: {
     // 表单验证
     handleSubmit () {
       this.$refs['formValidate'].validate(valid => {
         if (valid) {
           // saveChannel(this.formValidate)
           //   .then(res => {
           //     this.$Message.success(res.msg)
           //     setTimeout(() => this.close(), 1000)
           //   }).catch(err => {
           //     this.$Message.error(err.msg)
           //   })
           this.$Message.success('成功!')
         } else {
           this.$Message.error('表单验证失败!')
         }
       })
     },
     //关闭标签页
     ...mapMutations([
       'closeTag'
     ]),
     close () {
       console.log(this.$route.params.row)
       this.closeTag({
         name: 'rate',
         params: {
           row: this.$route.params.row
         }
       })
     },
     // 返回按钮
     btnClick1 () {
       this.close()
     }
   }
 };
 </script>
 <style lang="less">
  .rate-item {
    width: 60%;
  }
  .rate-item .ivu-form-item-label {
    font-size: 14px;
  }
 </style>
